home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / database / sizeof / sizeof.asm next >
Assembly Source File  |  1987-06-09  |  2KB  |  78 lines

  1. ; SIZEOF.ASM  -- returns size in bytes of specified file
  2. ; returns 0 if file not found or error opening file
  3. ; SYNTAX:  i = sizeof(<filename.ext>)
  4. ; EXAMPLE: i = sizeof(sizeof.asm)
  5. ; returns: i = 1794
  6. ;
  7. ; by Gary Gruber
  8. ; Data Base Designs
  9. ; 71-533 Tangier Rd.
  10. ; Rancho Mirage, Ca. 92270
  11. ; 619-568-4338
  12. ;
  13. public  sizeof
  14. extrn _parc:far
  15. extrn _retnl:far
  16. extrn _retni:far
  17. ;
  18. _PROG   segment byte public '_PROG'
  19. sizeof          proc    far
  20.         assume  cs:_PROG,ds:_PROG,es:_PROG
  21.         push    bp              ;normal clipper set up
  22.         mov     bp,sp
  23.         push    ds
  24.         push    es
  25.         cld
  26. get_file:
  27.         mov     ax,1            ;get file name
  28.         push    ax
  29.         call    _parc
  30.         add     sp,2
  31.         mov     ds,ax           ;DS points to segment address of parameter
  32.         mov     dx,bx           ;put file name here
  33. open_file:
  34.         mov     ah,3dh          ;DOS open file function
  35.         xor     al,al
  36.         int     21h
  37.         jc      error           ; file not found?
  38. get_size:       
  39.         mov     bx,ax           ;put the file name here
  40.         xor     dx,dx           
  41.         xor     cx,cx
  42.         mov     ah,42h          ;move pointer function          
  43.         mov     al,2            ;go to end of file
  44.         int     21h
  45.         jnc     return
  46. error:
  47.         xor     ax,ax           ; return 0 bytes     
  48.         xor     dx,dx            
  49. return:
  50.         push    ax
  51.         mov     ah,3eh
  52.         int     21h
  53.         pop     ax
  54.         pop     es
  55.         pop     ds
  56.         pop     bp
  57.         cmp     dx,0            ;Is file larger than 64K?
  58.         jnz     return_long
  59. return_int:
  60.         push    ax
  61.         call    _retni 
  62.         add     sp,2
  63.         jmp     exit
  64. return_long:
  65.         mov     bx,dx
  66.         xchg    ax,bx
  67.         push    ax
  68.         push    bx
  69.         call    _retnl
  70.         add     sp,4
  71. exit:
  72.         ret
  73. sizeof  endp
  74. _PROG   ends
  75.         end
  76.  
  77.  
  78.